package com.qili.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qili.core.utils.DictTypes;
import com.qili.entity.sys.SysRegion;
import com.qili.entity.sys.dto.SysUserDTO;
import com.qili.mapper.sys.SysUserMapper;
import com.qili.service.sys.SysRegionService;
import com.qili.util.ReType;
import com.qili.util.StringUtil;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author zhaoyongke
 * @date 2021/5/25
 * @description 企业信息统计
 */
@RequestMapping("/search/decision")
@Controller
public class ComInfoTjController {

    @Autowired
    SysUserMapper sysUserMapper;
    @Autowired
    SysRegionService sysRegionService;

    @GetMapping("comInfoTjIndex")
    @RequiresPermissions("zn:jc:xxtj")
    public String comInfoTjIndex(Model model) {

        // 省
        List<SysRegion> provincelist = sysRegionService.selectListByLevelId("1");
        // 市
        List<SysRegion> citylist = sysRegionService.selectListByLevelId("2");
        model.addAttribute("provincelist", provincelist);
        return "/decision/comTj/comInfoTjIndex";
    }

    /*
     * @Author:zhaoyongke
     * @Description:
     * @param model
     * @Date:13:03 2021/5/17
     */
    @GetMapping("/certTjDetail")
    public String certTjDetail(Model model, SysUserDTO dto) {
        String id = dto.getId();
        String companyName = dto.getCompanyName();
        model.addAttribute("companyName", companyName);
        model.addAttribute("id", id);
        return "/decision/comTj/certTjDetail";
    }

    /**
     * @param dto
     * @param model
     * @param page
     * @param limit
     * @Author:zhaoyongke
     * @Description:
     * @Date:14:37 2021/5/25
     */
    @GetMapping(value = "/selectComTjList")
    @ResponseBody
    public ReType selectComTjList(SysUserDTO dto, Model model, String page, String limit) {
        Page<SysUserDTO> tPage = PageHelper.startPage(Integer.valueOf(page), Integer.valueOf(limit));
        ReType re = new ReType();
        List<SysUserDTO> sysUserDTOS = sysUserMapper.selectComTjList(dto);
        re.setPageNum(Long.valueOf(page));
        re.setCount(tPage.getTotal());
        re.setData(sysUserDTOS);
        return re;

    }


}
